\(\int \frac {\tan ^2(x)}{a+a \csc (x)} \, dx\) [3]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [C] (verified)
   Fricas [A] (verification not implemented)
   Sympy [F]
   Maxima [B] (verification not implemented)
   Giac [A] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 13, antiderivative size = 39 \[ \int \frac {\tan ^2(x)}{a+a \csc (x)} \, dx=-\frac {x}{a}+\frac {(3-2 \csc (x)) \tan (x)}{3 a}-\frac {(1-\csc (x)) \tan ^3(x)}{3 a} \]

[Out]

-x/a+1/3*(3-2*csc(x))*tan(x)/a-1/3*(1-csc(x))*tan(x)^3/a

Rubi [A] (verified)

Time = 0.11 (sec) , antiderivative size = 39, normalized size of antiderivative = 1.00, number of steps used = 4, number of rules used = 3, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.231, Rules used = {3973, 3967, 8} \[ \int \frac {\tan ^2(x)}{a+a \csc (x)} \, dx=-\frac {x}{a}-\frac {\tan ^3(x) (1-\csc (x))}{3 a}+\frac {\tan (x) (3-2 \csc (x))}{3 a} \]

[In]

Int[Tan[x]^2/(a + a*Csc[x]),x]

[Out]

-(x/a) + ((3 - 2*Csc[x])*Tan[x])/(3*a) - ((1 - Csc[x])*Tan[x]^3)/(3*a)

Rule 8

Int[a_, x_Symbol] :> Simp[a*x, x] /; FreeQ[a, x]

Rule 3967

Int[(cot[(c_.) + (d_.)*(x_)]*(e_.))^(m_)*(csc[(c_.) + (d_.)*(x_)]*(b_.) + (a_)), x_Symbol] :> Simp[(-(e*Cot[c
+ d*x])^(m + 1))*((a + b*Csc[c + d*x])/(d*e*(m + 1))), x] - Dist[1/(e^2*(m + 1)), Int[(e*Cot[c + d*x])^(m + 2)
*(a*(m + 1) + b*(m + 2)*Csc[c + d*x]), x], x] /; FreeQ[{a, b, c, d, e}, x] && LtQ[m, -1]

Rule 3973

Int[(cot[(c_.) + (d_.)*(x_)]*(e_.))^(m_)*(csc[(c_.) + (d_.)*(x_)]*(b_.) + (a_))^(n_), x_Symbol] :> Dist[a^(2*n
)/e^(2*n), Int[(e*Cot[c + d*x])^(m + 2*n)/(-a + b*Csc[c + d*x])^n, x], x] /; FreeQ[{a, b, c, d, e, m}, x] && E
qQ[a^2 - b^2, 0] && ILtQ[n, 0]

Rubi steps \begin{align*} \text {integral}& = \frac {\int (-a+a \csc (x)) \tan ^4(x) \, dx}{a^2} \\ & = -\frac {(1-\csc (x)) \tan ^3(x)}{3 a}+\frac {\int (3 a-2 a \csc (x)) \tan ^2(x) \, dx}{3 a^2} \\ & = \frac {(3-2 \csc (x)) \tan (x)}{3 a}-\frac {(1-\csc (x)) \tan ^3(x)}{3 a}+\frac {\int -3 a \, dx}{3 a^2} \\ & = -\frac {x}{a}+\frac {(3-2 \csc (x)) \tan (x)}{3 a}-\frac {(1-\csc (x)) \tan ^3(x)}{3 a} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.23 (sec) , antiderivative size = 62, normalized size of antiderivative = 1.59 \[ \int \frac {\tan ^2(x)}{a+a \csc (x)} \, dx=-\frac {4 \cos (2 x)-2 \sin (x)+(-5+6 x) \cos (x) (1+\sin (x))}{6 a \left (\cos \left (\frac {x}{2}\right )-\sin \left (\frac {x}{2}\right )\right ) \left (\cos \left (\frac {x}{2}\right )+\sin \left (\frac {x}{2}\right )\right )^3} \]

[In]

Integrate[Tan[x]^2/(a + a*Csc[x]),x]

[Out]

-1/6*(4*Cos[2*x] - 2*Sin[x] + (-5 + 6*x)*Cos[x]*(1 + Sin[x]))/(a*(Cos[x/2] - Sin[x/2])*(Cos[x/2] + Sin[x/2])^3
)

Maple [C] (verified)

Result contains complex when optimal does not.

Time = 0.34 (sec) , antiderivative size = 50, normalized size of antiderivative = 1.28

method result size
risch \(-\frac {x}{a}-\frac {2 \left (5 \,{\mathrm e}^{i x}+4 i+3 \,{\mathrm e}^{3 i x}\right )}{3 \left (i+{\mathrm e}^{i x}\right )^{3} \left ({\mathrm e}^{i x}-i\right ) a}\) \(50\)
default \(\frac {-2 \arctan \left (\tan \left (\frac {x}{2}\right )\right )+\frac {2}{3 \left (\tan \left (\frac {x}{2}\right )+1\right )^{3}}-\frac {1}{\left (\tan \left (\frac {x}{2}\right )+1\right )^{2}}-\frac {3}{2 \left (\tan \left (\frac {x}{2}\right )+1\right )}-\frac {1}{2 \left (\tan \left (\frac {x}{2}\right )-1\right )}}{a}\) \(54\)

[In]

int(tan(x)^2/(a+a*csc(x)),x,method=_RETURNVERBOSE)

[Out]

-x/a-2/3*(5*exp(I*x)+4*I+3*exp(3*I*x))/(I+exp(I*x))^3/(exp(I*x)-I)/a

Fricas [A] (verification not implemented)

none

Time = 0.24 (sec) , antiderivative size = 38, normalized size of antiderivative = 0.97 \[ \int \frac {\tan ^2(x)}{a+a \csc (x)} \, dx=-\frac {3 \, x \cos \left (x\right ) + 4 \, \cos \left (x\right )^{2} + {\left (3 \, x \cos \left (x\right ) - 1\right )} \sin \left (x\right ) - 2}{3 \, {\left (a \cos \left (x\right ) \sin \left (x\right ) + a \cos \left (x\right )\right )}} \]

[In]

integrate(tan(x)^2/(a+a*csc(x)),x, algorithm="fricas")

[Out]

-1/3*(3*x*cos(x) + 4*cos(x)^2 + (3*x*cos(x) - 1)*sin(x) - 2)/(a*cos(x)*sin(x) + a*cos(x))

Sympy [F]

\[ \int \frac {\tan ^2(x)}{a+a \csc (x)} \, dx=\frac {\int \frac {\tan ^{2}{\left (x \right )}}{\csc {\left (x \right )} + 1}\, dx}{a} \]

[In]

integrate(tan(x)**2/(a+a*csc(x)),x)

[Out]

Integral(tan(x)**2/(csc(x) + 1), x)/a

Maxima [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 94 vs. \(2 (33) = 66\).

Time = 0.31 (sec) , antiderivative size = 94, normalized size of antiderivative = 2.41 \[ \int \frac {\tan ^2(x)}{a+a \csc (x)} \, dx=-\frac {2 \, {\left (\frac {\sin \left (x\right )}{\cos \left (x\right ) + 1} - \frac {6 \, \sin \left (x\right )^{2}}{{\left (\cos \left (x\right ) + 1\right )}^{2}} - \frac {3 \, \sin \left (x\right )^{3}}{{\left (\cos \left (x\right ) + 1\right )}^{3}} + 2\right )}}{3 \, {\left (a + \frac {2 \, a \sin \left (x\right )}{\cos \left (x\right ) + 1} - \frac {2 \, a \sin \left (x\right )^{3}}{{\left (\cos \left (x\right ) + 1\right )}^{3}} - \frac {a \sin \left (x\right )^{4}}{{\left (\cos \left (x\right ) + 1\right )}^{4}}\right )}} - \frac {2 \, \arctan \left (\frac {\sin \left (x\right )}{\cos \left (x\right ) + 1}\right )}{a} \]

[In]

integrate(tan(x)^2/(a+a*csc(x)),x, algorithm="maxima")

[Out]

-2/3*(sin(x)/(cos(x) + 1) - 6*sin(x)^2/(cos(x) + 1)^2 - 3*sin(x)^3/(cos(x) + 1)^3 + 2)/(a + 2*a*sin(x)/(cos(x)
 + 1) - 2*a*sin(x)^3/(cos(x) + 1)^3 - a*sin(x)^4/(cos(x) + 1)^4) - 2*arctan(sin(x)/(cos(x) + 1))/a

Giac [A] (verification not implemented)

none

Time = 0.28 (sec) , antiderivative size = 49, normalized size of antiderivative = 1.26 \[ \int \frac {\tan ^2(x)}{a+a \csc (x)} \, dx=-\frac {x}{a} - \frac {1}{2 \, a {\left (\tan \left (\frac {1}{2} \, x\right ) - 1\right )}} - \frac {9 \, \tan \left (\frac {1}{2} \, x\right )^{2} + 24 \, \tan \left (\frac {1}{2} \, x\right ) + 11}{6 \, a {\left (\tan \left (\frac {1}{2} \, x\right ) + 1\right )}^{3}} \]

[In]

integrate(tan(x)^2/(a+a*csc(x)),x, algorithm="giac")

[Out]

-x/a - 1/2/(a*(tan(1/2*x) - 1)) - 1/6*(9*tan(1/2*x)^2 + 24*tan(1/2*x) + 11)/(a*(tan(1/2*x) + 1)^3)

Mupad [B] (verification not implemented)

Time = 19.84 (sec) , antiderivative size = 51, normalized size of antiderivative = 1.31 \[ \int \frac {\tan ^2(x)}{a+a \csc (x)} \, dx=\frac {-2\,{\mathrm {tan}\left (\frac {x}{2}\right )}^3-4\,{\mathrm {tan}\left (\frac {x}{2}\right )}^2+\frac {2\,\mathrm {tan}\left (\frac {x}{2}\right )}{3}+\frac {4}{3}}{a\,\left (\mathrm {tan}\left (\frac {x}{2}\right )-1\right )\,{\left (\mathrm {tan}\left (\frac {x}{2}\right )+1\right )}^3}-\frac {x}{a} \]

[In]

int(tan(x)^2/(a + a/sin(x)),x)

[Out]

((2*tan(x/2))/3 - 4*tan(x/2)^2 - 2*tan(x/2)^3 + 4/3)/(a*(tan(x/2) - 1)*(tan(x/2) + 1)^3) - x/a